home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / misc-part1 / 7921 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.7 KB

  1. Path: god.bel.alcatel.be!nlev00!barnhoorn
  2. From: barnhoorn@nlev00 ()
  3. Newsgroups: comp.sys.amiga.programmer,comp.sys.amiga.misc,comp.sys.amiga.hardware
  4. Subject: Re: CIA
  5. Date: 13 Mar 1996 11:40:43 GMT
  6. Organization: Alcatel Bell
  7. Distribution: world
  8. Message-ID: <4i6c7r$fiq@btmpjg.god.bel.alcatel.be>
  9. References: <3145A310.61E1@fs1.ee.man.ac.uk>
  10. Reply-To: barnhoorn@nlev00 ()
  11. NNTP-Posting-Host: 138.203.178.61
  12. X-Newsreader: mxrn 6.18-10
  13.  
  14.  
  15. In article <3145A310.61E1@fs1.ee.man.ac.uk>, Christos Dimitrakakis <mbge4cd1@fs1.ee.man.ac.uk> writes:
  16. >Anyone willing to post me details on how the CIA chips work
  17. >and how I can use them for timing?
  18. >I would also require in-depth information on resource-allocating,
  19. >as well as asynchronous IO operations.
  20. >
  21. >Any help would be greatly appreciated.
  22. >
  23.  
  24. .that's all?
  25.  
  26. No need to use the CIA for timing - if you really want to access the
  27. CIA directly, then don't use the method described below, because in this
  28. example I use the official way of performing IO-operations.
  29.  
  30.        /* for the timeout */
  31.         struct MsgPort *tport;
  32.         struct timerequest tr;
  33.     unsigned long time=0L; /* in milliseconds */
  34.     unsigned long error;
  35.  
  36.                 if (time<1000)
  37.                         error=OpenDevice(TIMERNAME,UNIT_MICROHZ,(struct IORequest *)&tr,0);
  38.                 else
  39.                         error=OpenDevice(TIMERNAME,UNIT_VBLANK,(struct IORequest *)&tr,0);
  40.                 tport=CreatePort(0,0);
  41.                 /* now let's check for timer */
  42.                 if (error && !tport) {
  43.                         /* no... */
  44.                         if (tport) DeletePort(tport);
  45.                         if (!error) CloseDevice((struct IORequest *)&tr);
  46.                         /* now just use the old method of delaying... */
  47.                 } else {
  48.                         /* all initializing is done now */
  49.                         tr.tr_node.io_Message.mn_Node.ln_Type=NT_MESSAGE;
  50.                         tr.tr_node.io_Message.mn_Node.ln_Pri=0;
  51.                         tr.tr_node.io_Message.mn_Node.ln_Name=NULL;
  52.                         tr.tr_node.io_Message.mn_ReplyPort=tport;
  53.                         tr.tr_time.tv_secs=time/1000;
  54.                         tr.tr_time.tv_micro=(time%1000)*1000;
  55.                         tr.tr_node.io_Command=TR_ADDREQUEST;
  56.                         SendIO((struct IORequest *)&tr);
  57.                         waitflags|=1<<tport->mp_SigBit;
  58.         }
  59.  
  60. -- 
  61. ---------------------------------------------------------------------------
  62. Jaco Barnhoorn               barnie@xs4all.nl
  63. Software Test Engineer       barnhoorn%nlev00@btmv56.se.bel.alcatel.be
  64. Alcatel Telecom Systems
  65. Rijswijk, The Netherlands
  66. ---------------------------------------------------------------------------
  67.